import Vue from 'vue'
import App from './App'
import GoEasy from './lib/goeasy-1.0.17.js'
Vue.config.productionTip = false
import uView from "uview-ui";
import $http from '@/common/service.js'
Vue.use(uView);
App.mpType = 'app'
const msg = (title, duration=1500, mask=false, icon='none')=>{
	//统一提示方便全局修改
	if(Boolean(title) === false){
		return;
	}
	uni.showToast({
		title,
		duration,
		mask,
		icon
	});
}
Vue.prototype.msg = msg
Vue.filter('dateFormat', (originVal) => {
  const dt = new Date(originVal)
  const y = dt.getFullYear()
  const m = (dt.getMonth() + 1 + '').padStart(2, '0')
  const d = (dt.getDate() + '').padStart(2, '0')

  const hh = (dt.getHours() + '').padStart(2, '0')
  const mm = (dt.getMinutes() + '').padStart(2, '0')
  const ss = (dt.getSeconds() + '').padStart(2, '0')
 
  return `${y}-${m}-${d} ${hh}-${mm}-${ss}`
})
Vue.prototype.$http = $http;
// 在main.js里初始化全局的GoEasy对象
Vue.prototype.$goEasy = new GoEasy({
    host: "hangzhou.goeasy.io", //应用所在的区域地址: 【hangzhou.goeasy.io | singapore.goeasy.io】
    appkey: "BC-1ec756cabfc142959d48fa83cce60e23", //替换为您的应用appkey
    onConnected: function() {
        console.log('连接成功！')
    },
    onDisconnected: function() {
        console.log('连接断开！')
    },
    onConnectFailed: function(error) {
        console.log('连接失败或错误！')
    }
});
const app = new Vue({
    ...App
})
app.$mount()
